<template>
  <div class="audit">
    <!--备案处置-->
    <div>
      <div class="czInfo">
        <div>备案信息</div>
      </div>
      <van-form>
        <van-field
          autosize
          readonly
          input-align="right"
          label="驾驶员姓名"
          v-model="formData.driver_name"
        />
        <van-field
          autosize
          readonly
          input-align="right"
          label="驾驶员身份证号"
          v-model="formData.driver_cardno"
        />
        <van-field
          autosize
          readonly
          input-align="right"
          label="驾驶员手机号码"
          v-model="formData.driver_tel"
        />
        <div class="field">
          <div class="label">是否途经风险地区</div>
          <div class="text">
            <div
              :class="{ 'icon': formData.quguo_high_risk == '1', 'icon1': formData.quguo_high_risk == '2' }"
            ></div>
            <div
              :class="{ 'value': formData.quguo_high_risk == '1', 'value1': formData.quguo_high_risk == '2' }"
            >{{ formData.quguo_high_risk == '1' ? '未途经' : formData.quguo_high_risk == '2' ? '途经' : formData.quguo_high_risk == '3' ? '未查询到行程记录' : '' }}</div>
          </div>
        </div>
        <van-field
          autosize
          readonly
          input-align="right"
          label="最新核酸检测结果"
          v-model="formData.hesuan_result1"
        />
        <van-field
          autosize
          readonly
          input-align="right"
          label="车牌号码"
          v-model="formData.car_number"
        />
        <van-field
          autosize
          readonly
          input-align="right"
          label="车牌颜色"
          v-model="formData.chepai_color_name"
        />
        <!-- <van-field autosize readonly input-align="right" label="运输证号" v-model="formData.dlys_no" /> -->
        <!-- <van-field
          autosize
          readonly
          input-align="right"
          label="从业证号"
          v-model="formData.people_cy_no"
        /> -->
        <van-field
          v-if="isInAndOuts == 2"
          autosize
          readonly
          input-align="right"
          label="出发地"
          v-model="formData.origin"
        />
        <!-- <van-field
          v-if="isInAndOuts == 2"
          autosize
          readonly
          input-align="right"
          label="途经地"
          v-model="formData.tjd"
        /> -->
        <van-field
          v-if="isInAndOuts == 2"
          autosize
          readonly
          input-align="right"
          label="来返沈时间"
          v-model="formData.arrive_time"
        />
        <van-field
          v-if="isInAndOuts == 1"
          autosize
          readonly
          input-align="right"
          label="离沈时间"
          v-model="formData.arrive_time"
        />
        <van-field autosize readonly input-align="right" label="在沈时间" v-model="formData.zssj_name" />
        <van-field
          v-if="isInAndOuts == 2 && formData.zssj_name == '在沈过夜'"
          autosize
          readonly
          input-align="right"
          label="来返沈住址"
          v-model="formData.arrive_address"
        />
        <van-field
          v-if="isInAndOuts == 2"
          input-align="right"
          label="到沈区域"
          readonly
          name="pattern"
          v-model="formData.dsqName"
        />
        <van-field
          v-if="isInAndOuts == 1"
          autosize
          readonly
          input-align="right"
          label="目的地"
          v-model="formData.origin"
        />
        <div v-if="isInAndOuts == 2 || isInAndOuts == 3">
          <div class="czInfo">
            <div>货主信息</div>
          </div>
          <div v-for="(item, index) in formData.goodsList" :key="index">
            <!-- 入沈是卸货  出沈是装货-->
            <!-- <van-field
              input-align="right"
              v-if="isInAndOuts != 1"
              :label="'装货地点' + (index + 1)"
              readonly
              name="pattern"
              placeholder="装货地点"
              :value="formData.goodsList[index].goods_pretend ? formData.goodsList[index].goods_pretend_s + ',' + formData.goodsList[index].goods_pretend : ''"
            /> -->
            <!-- <van-field
              input-align="right"
              v-if="isInAndOuts != 3"
              :label="'卸货区' + (index + 1)"
              readonly
              name="pattern"
              placeholder="请选择卸货区"
              v-model="formData.goodsList[index].ascription_code_name"
            /> -->
            <!-- <van-field
              input-align="right"
              v-if="isInAndOuts != 3"
              readonly
              :label="'卸货地点' + (index + 1)"
              v-model="formData.goodsList[index].goods_discharge"
              name="pattern"
            /> -->
            <van-field
              input-align="right"
              v-if="isInAndOuts != 3"
              readonly
              :label="'收发货单位' + (index + 1)"
              v-model="formData.goodsList[index].receiving_dw"
              name="pattern"
            />
            <van-field
              input-align="right"
              v-if="isInAndOuts != 3"
              readonly
              :label="'收发货人姓名' + (index + 1)"
              v-model="formData.goodsList[index].receiving_name"
              name="pattern"
              placeholder="请输入收货人姓名"
            />
            <van-field
              input-align="right"
              v-if="isInAndOuts != 3"
              readonly
              :label="'收发货人手机号码' + (index + 1)"
              v-model="formData.goodsList[index].receiving_tel"
              name="pattern"
              placeholder="请输入收货人手机号码"
            />
          </div>
        </div>
        <div class="czInfo">
          <div>同行信息</div>
        </div>
        <div v-for="(item, index) in formData.peerList" :key="index + 'p'">
          <van-field
            autosize
            readonly
            input-align="right"
            :label="'同行人姓名' + (index + 1)"
            v-model="formData.peerList[index].passenger_name"
          />
          <van-field
            autosize
            readonly
            input-align="right"
            :label="'同行人身份证号' + (index + 1)"
            v-model="formData.peerList[index].passenger_cardno"
          />
          <van-field
            autosize
            readonly
            input-align="right"
            :label="'同行人手机号码' + (index + 1)"
            v-model="formData.peerList[index].passenger_tel"
          />
          <div class="field">
            <div class="label">是否途经风险地区</div>
            <div class="text">
              <div
                :class="{ 'icon': formData.peerList[index].quguo_high_risk == '1', 'icon1': formData.peerList[index].quguo_high_risk == '2' }"
              ></div>
              <div
                :class="{ 'value': formData.peerList[index].quguo_high_risk == '1', 'value1': formData.peerList[index].quguo_high_risk == '2' }"
              >{{ formData.peerList[index].quguo_high_risk == '1' ? '未途经' : formData.peerList[index].quguo_high_risk == '2' ? '途经' : formData.peerList[index].quguo_high_risk == '3' ? '未查询到行程记录' : '' }}</div>
            </div>
          </div>
          <van-field
            autosize
            readonly
            input-align="right"
            label="最新核酸检测结果"
            v-model="formData.peerList[index].hesuan_result1"
          />
          <van-button
            type="primary"
            :disabled="formData.peerList[index].checkBtnTxt == '比对成功' || $route.query.worker_type !='GA'"
            @click="checkBtn(index)"
            block
          >{{ formData.peerList[index].checkBtnTxt }}</van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>
<script>
import { Toast } from 'vant'
import {
  distinguishSstErCode
} from '../../../api/gov/home/index'
export default {
  props: {
    formData: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data () {
    return {
      isInAndOuts: ''
    }
  },
  mounted () {
    this.isInAndOuts = this.$route.query.value
    console.log('info query.value', this.$route.query.value)
  },
  methods: {
    // 同行人 身份核验
    checkBtn (index) {
      const name = this.formData.peerList[index].passenger_name // 姓名
      const cardNo = this.formData.peerList[index].passenger_cardno // 身份证号
      this.$hdsdk.scanQrCode().then(res => {
        if (!!res && res.code == 0 && !!res.data && !!res.data.scanResult) {
          distinguishSstErCode({ ecQrCode: res.data.scanResult }).then(ret => {
            console.log(ret, '获取用户信息')
            if (cardNo == ret.data.data.data.cardNo && name == ret.data.data.data.userName) {
              this.formData.peerList[index].checkBtnTxt = '比对成功'
              this.formData.peerList[index].infoType = false
              Toast.success('核验成功')
            } else {
              this.formData.peerList[index].infoType = true
              Toast.success('与备案信息不符')
            }
            this.$emit('checkBtn', this.formData.peerList)
          })
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
.audit {
  .title {
    padding: 0.533rem 0.853rem;
    font-size: 0.747rem;
    color: #646566;
  }
  /deep/.van-field__label {
    width: 9em;
    display: flex;
    align-items: center;
  }
  .img_list {
    margin: 20px 0.853rem;
    display: flex;
    img {
      width: 120px;
      height: 120px;
      margin-right: 20px;
    }
  }
}
.czInfo {
  height: 80px;
  font-size: 32px;
  //font-weight: bold;
  //color: white;
  //background-color: #58be6a;
  background-color: #eee;
  display: flex;
  align-items: center;
  div {
    width: 690px;
    margin: 0 auto;
  }
}
.nucleicAcid {
  width: 690px;
  margin: 40px auto;
  border-radius: 20px;
  overflow: hidden;
  box-sizing: border-box;
  //border: 1px solid #DDEEE3;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  .title {
    text-align: center;
    font-size: 28px;
    color: white;
    background-color: #58be6a;
  }
}
.btn {
  width: 150px;
}
.field {
  width: 690px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #ebedf0;
  margin: 0 auto;
  box-sizing: border-box;
  .label {
    font-size: 28px;
    color: #646566;
    flex-shrink: 0;
  }
  .text {
    font-size: 28px;
    color: #646566;
    display: flex;
    align-items: center;
    .icon {
      width: 15px;
      height: 15px;
      border-radius: 15px;
      background-color: #58be6a;
      flex-shrink: 0;
      margin-right: 5px;
    }
    .icon1 {
      width: 15px;
      height: 15px;
      border-radius: 15px;
      flex-shrink: 0;
      background-color: red;
      margin-right: 5px;
    }
    .value {
      color: #58be6a;
    }
    .value1 {
      color: red;
    }
  }
}
.concentrated /deep/.van-field__label {
  width: 6.3em;
}
//.concentrated /deep/ .van-radio--horizontal{
//  margin-top: 10px;
//  margin-left: 160px;
//}
.btnClass {
  width: 95%;
  margin: 20px 18px;
}
.mapOut {
  width: 690px;
  height: 1000px;
  background-color: white;
  .title {
    height: 60px;
    line-height: 60px;
    font-size: 32px;
    text-align: center;
  }
}
.trip /deep/.van-field__label {
  width: 8em;
}
</style>
